#include <iostream>
#include <string>

enum class State { Start, String, Escape, End };

std::string extractStrings(const std::string& sourceCode) {
    std::string extractedStrings;
    State currentState = State::Start;
    std::string currentString;

    for (char ch : sourceCode) {
        switch (currentState) {
            case State::Start:
                if (ch == '"') {
                    currentState = State::String;
                    currentString.clear();
                }
                break;
            case State::String:
                if (ch == '\\') {
                    currentState = State::Escape;
                } else if (ch == '"') {
                    currentState = State::End;
                    extractedStrings += currentString;
                } else {
                    currentString += ch;
                }
                break;
            case State::Escape:
                currentString += ch;
                currentState = State::String;
                break;
            case State::End:
                currentState = State::Start;
                break;
        }
    }

    return extractedStrings;
}

int main() {
    std::string sourceCode = "一般学习一门编程语言的时候，基本上第一个程序是输出\\\"Hello World!\\\"";
    std::string extractedStrings = extractStrings(sourceCode);
    std::cout << "提取的字符串为：" << extractedStrings << std::endl;
    return 0;
}